package org.zxn.study.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.zxn.study.factory.impl.UserLoginFactory;
import org.zxn.study.req.LoginReq;
import org.zxn.study.rsp.LoginResp;
import org.zxn.study.strategy.UserGranter;

/**
 * @ClassName UserService
 * @Description: 用户登录服务
 * @Author zxn
 * @Date 2025/7/10 11:46
 **/
@Service
public class UserLoginService {

    @Autowired
    private UserLoginFactory factory;

    public LoginResp login(LoginReq loginReq){
        UserGranter granter = factory.getGranter(loginReq.getType());
        if(granter == null){
            LoginResp loginResp = new LoginResp();
            loginResp.setSuccess(false);
            return loginResp;
        }
        return granter.login(loginReq);
    }
}